package jaux.tank.admin.core.util;

import java.util.ArrayList;
import java.util.List;

import jaux.tank.admin.config.properties.TankProperties;
import jaux.tank.bean.constant.Const;
import jaux.tank.bean.vo.SpringContextHolder;
import jaux.tank.bean.vo.node.MenuNode;

/**
 * api接口文档显示过滤
 *
 * @date 2017-08-17 16:55
 */
public class ApiMenuFilter extends MenuNode {


    public static List<MenuNode> build(List<MenuNode> nodes) {

        //如果关闭了接口文档,则不显示接口文档菜单
        TankProperties tankProperties = SpringContextHolder.getBean(TankProperties.class);
        if (Boolean.TRUE.equals(tankProperties.getSwaggerOpen())) {
        	return nodes;
		}
        List<MenuNode> menuNodesCopy = new ArrayList<>();
        for (MenuNode menuNode : nodes) {
            if (!Const.API_MENU_NAME.equals(menuNode.getName())) {
                menuNodesCopy.add(menuNode);
            }
        }

        return menuNodesCopy;
    }
}
